<template>
  <div>
    <a-modal
      :visible.sync="visible"
      title="科技管理策划版本"
      width="760px"
      @cancel="cancelSub"
      centered
    >
      <s-table
        ref="table"
        table-layout="fixed"
        size="default"
        row-key="id"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :show-pagination="false"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="handleSub(record, 'view')">查看</a>
        </span>
      </s-table>
      <template slot="footer">
        <a-button  @click="cancelSub">
          关闭
        </a-button>
      </template>
    </a-modal>
  </div>
</template>
<script>

import { STable } from '@/components'
export default {
    name: 'AddModal',
    props: {
      visible: {
        type: Boolean,
        default() {
            return true
        }
      },
      list: {
        type: Array,
        default() {
          return []
        }
      },
    },
    components: {
    },
    data() {
        return {
          columns: [
            {
              title: '序号',
              scopedSlots: { customRender: 'serial' },
              customRender: (value, row, index) => {
                return index + 1
              }
            },
            {
              title: '版本号',
              dataIndex: 'businessVersion',
              customRender: (value, row, index) => {
                return "V" + row.businessVersion
              }
            },
            {
              title: '填报人',
              dataIndex: 'creatorName',
            },
            {
              title: '填报时间',
              dataIndex: 'createTime',
            },
            {
              title: '操作',
              dataIndex: 'action',
              width: '100px',
              scopedSlots: { customRender: 'action' },
            },
          ],
          loadData: (parameter) => {
            return new Promise((resolve, reject) => {
              const list = this.list.sort((a, b) => {
                return a.businessVersion - b.businessVersion
              })
              resolve({
                code: 200,
                data: list
              })
            })
          },
          sexMap: [
            {id: '0', name: '男'},
            {id: '1', name: '女'}
          ],
        }
    },
    watch: {
      visible: {
        handler(nv, old) {
          if (nv) {
            this.$nextTick(() => {
              this.$refs.table.refresh()
            })
          }
        }
      },
    },
    computed: {
    },
    created() {
    },
    mounted() {
    },
    methods: {
      cancelSub(reset) {
        this.$emit('update:visible', false)
      },
      handleSub(record, type) {
        this.$router.push({ name: '/science/plots/addPlots', query: { id: record.id, type: type } })
      },
    },
}
</script>
<style lang="less" scoped>
  .flex-model-form .ant-form-item{
    display: flex;
  }
  .upload-list .ant-upload-list {
    // display: contents;
  }
</style>